<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"
	      name="viewport"/>

	<!-- 所有的 css 资源 -->
	<link href="https://cdn.bootcss.com/element-ui/2.12.0/theme-chalk/index.css" rel="stylesheet">
	<link href="/static/sa.css" rel="stylesheet">

	<!-- 所有的 js 资源 -->
	<script src="https://cdn.bootcss.com/vue/2.6.10/vue.js"></script>
	<script src="https://cdn.bootcss.com/element-ui/2.12.0/index.js"></script>
	<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
	<script src="https://cdn.bootcss.com/layer/3.0.1/layer.min.js"></script>
	<script src="/res/sa.js"></script>

	<style type="text/css">

	</style>

</head>
<body>

<!-- 防止margin向下击穿 -->
<div style="margin-top: -1em;"><br></div>

<div class="vue-box">

	<!-- 参数栏 -->
	<div class="c-panel">
		<el-form ref="form">
			<div class="c-item">
				<label class="c-label">用户名：</label>
				<el-input size="mini" v-model="user.name"></el-input>
			</div>
			<br/>
			<div class="c-item">
				<label class="c-label">密码：</label>
				<el-input size="mini" v-model="user.password"></el-input>
			</div>
			<br/>
			<el-row class="row-bg" justify="space-around" type="flex">
				<el-button @click="ok" size="mini" type="primary">确定</el-button>
			</el-row>

		</el-form>

	</div>
</div>


<script type="text/javascript">

    new Vue({
        el: '.vue-box',
        data: {
            user: {	// 查询参数
                name: '',
                password: '',
            }
        },
        methods: {
            // ok
            ok: function (pageNo) {
                sa.post("/user", this.user, function (res) {
                    if (res && res.state && res.data) {
                        layer.alert('添加成功', {}, function () {
                            let curr_index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.app.f5();
                            parent.layer.close(curr_index); //再执行关闭
                            layer.closeAll();
                        });
                    }
                })
            },

        }
    })

</script>


</body>
</html>
